<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="shortcut icon" type="image/x-icon" href="__PUBLIC__/Home/Support/images/icon_120.ico" media="screen" /> 
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Home/Support/css/layout.css" media="all" />
<script type="text/javascript" src="__PUBLIC__/Home/Support/js/jquery-1.7.2.min.js"></script>
<meta name="description" content="E-MBA云 2015年你有啥梦想。梦想是可以有的，万一实现了呢" />
<meta name="keywords" content="E-MBA云" />
<title>E-MBA云 2015年你有啥梦想-发布梦想</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">
<!-- Mobile Devices Support @begin -->
<meta content="application/xhtml+xml;charset=UTF-8" http-equiv="Content-Type">
<meta content="no-cache,must-revalidate" http-equiv="Cache-Control">
<meta content="no-cache" http-equiv="pragma">
<meta content="0" http-equiv="expires">
<meta content="telephone=no, address=no" name="format-detection">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<meta name="apple-mobile-web-app-capable" content="yes" />
<!-- apple devices fullscreen -->
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<!-- Mobile Devices Support @end -->
</head>
<body class="body">
     <div class="dream_banner">
    	 <img src="__PUBLIC__/Home/Support/images/banner1.jpg"/>
    </div>	
    <div class="hello_box1">
    	<ul class="input">
    		<input type="hidden" id="dream_id" value="{$dream_info.dream_id}">
    		<notempty name="dream_info.dream_id">
        	标题：{$dream_info.dream_title}
        	<input type="hidden" id="dream_title" value="{$dream_info.dream_title}" />
    		<else />
    		<input type="text" id="dream_title" value="{$dream_info.dream_title}" placeholder="梦想标题（走遍世界的每个角落）" />
    		</notempty>
            <textarea id="dream_content" placeholder="梦想简介（趁着年轻的时候，背起行囊，走遍世界的每一个角落，有TA在我身边；等到老了的时候，面朝大海，看尽每一季的春暖花开，还有TA在我身边。）">{$dream_info.dream_content}</textarea>
        </ul>
        <ul class="btn">
            <button type="button" class="pre"  onclick="checkLogin()" id="tijiao">提交</button>
            <button type="button" class="pre" id="notijiao">提交中...</button>
        </ul>
    </div>
</body>
</html>
<script type="text/javascript">
	$(function($) {
		$("#notijiao").hide();
		$("#tijiao").show();
	});

    function isPhone(str){
        return str.match(RegExp("^1[34578][0-9]{9}$","g"));
    }

	function checkLogin() {
		var user_id = "{$Think.session.wap_user_id}"; //1;//
		var user_name = "{$Think.session.wap_user_name}";//'张三';//
		if(user_id == '' || user_id == 0 || user_id == undefined || user_name == '' || user_name == undefined ){
			alert("请您登陆后再发布梦想");
			return false;
		}
		
		var dream_id = $("#dream_id").val();
		var dream_title = $("#dream_title").val();
        var dream_content = $("#dream_content").val();
        if(dream_title == ''){
            alert("请输入梦想标题");
            return false;
        }
        if(dream_title.length > 15){
            alert("梦想标题请勿超过15个字符");
            return false;
        }
        if(dream_content == ''){
            alert("请输入梦想内容");
            return false;
        }
        //判断是否为微信发布
        if(isWeiXin()){
        	var from_type = 1;
        }else{
        	var from_type = 0;
        }
        $("#notijiao").show();
        $("#tijiao").hide();
        var post_data={
       		'dream_title':dream_title,
       		'dream_content' : dream_content,
       		'from_type'		: from_type,
       		'dream_id' : dream_id
        };
        $.ajax({
            type: "POST",
            url:"/Index/addDream",
            data: post_data,
            success: function(data){
                if(data.status == '0'){
                	console.log(data.data);
                	var dream_user_id = "{$dream_user_id}";
                	window.location.href = "/Support/index?id="+data.data+"&dream_user_id="+dream_user_id;
                	return false;
                }else{
                	$("#notijiao").hide();
                	$("#tijiao").show();
                    alert(data.info);
                }

            },
            dataType:"json"
        });
    }
	/**
    /* 判断用户访问下载页面的浏览器是否为微信浏览器
    **/
    function isWeiXin(){
        var ua = window.navigator.userAgent.toLowerCase();
        if(ua.match(/MicroMessenger/i) == 'micromessenger'){
            return true;
        }else{
            return false;
        }
    }
</script>